import socket


def main():
    # 创建套接字
    tcp_server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    # 绑定本地信息
    tcp_server_socket.bind(('', 8080))
    # 让默认的套接字由主动变为被动
    tcp_server_socket.listen(128)

    # 等待客户端链接
    new_client_socket, clinet = tcp_server_socket.accept()

    # 接受发送的请求
    recv_data = new_client_socket.recv(1024)
    print(recv_data)

    # 回送数据
    new_client_socket.send('____ok_____'.encode('utf-8'))

    new_client_socket.close()
    tcp_server_socket.close()


if __name__ == '__main__':
    main()
